import request from '@/utils/request'

// 分页查询试卷列表
export function listPaper(query) {
  return request({
    url: '/paper2/list',
    method: 'get',
    params: query
  })
}

// 批量更新试卷状态
export function updateStatus(ids, status) {
  return request({
    url: '/paper2/status',
    method: 'put',
    params: { ids: ids.join(','), status }
  })
}

// 删除试卷
export function deletePaper(ids) {
  return request({
    url: '/paper2',
    method: 'delete',
    params: { ids: ids.join(',') }
  })
}

// 恢复试卷
export function recoverPaper(ids) {
  return request({
    url: '/paper2/recover',
    method: 'put',
    params: { ids: ids.join(',') }
  })
}

// 创建试卷
export function createPaper(data) {
  return request({
    url: '/paper2',
    method: 'post',
    data: data
  })
}

// 更新试卷
export function updatePaper(data) {
  return request({
    url: '/paper2',
    method: 'put',
    data: data
  })
}

// 获取试卷详情
export function getPaperDetail(paperId) {
  return request({
    url: `/paper2/${paperId}`,
    method: 'get'
  })
}


// 预览试卷
export function previewPaper(paperId) {
  return request({
    url: `/paper2/preview/${paperId}`,
    method: 'get'
  })
}

// 导出试卷
// export function exportPaper(paperId, type) {
//   return request({
//     url: `/paper2/export/${paperId}`,
//     method: 'get',
//     params: { exportType: type },
//     responseType: 'blob'
//   })
// }

// 导出试卷
export function exportPaper(paperId, exportType, options) {
  return request({
    url: `/paper2/export/${paperId}`,
    method: 'get',
    params: {
      exportType,
      showAnswers: options.showAnswers,
      showOptionAnswers: options.showOptionAnswers,
      showAnalysis: options.showAnalysis,
      showKnowledgePoints: options.showKnowledgePoints,
      showDifficulty: options.showDifficulty
    },
    responseType: 'blob'
  })
}

